package com.miao.common.utils;

import com.alibaba.fastjson.JSON;
import com.miao.common.entity.R;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author MiaoWenqing
 * @description: 返回结果配置类
 * @date 2021/1/16 16:09
 */
public class ResponseUtil {

    public static  void out(HttpServletResponse response, R r){
        response.setContentType("application/json;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Method", "POST,GET");
        try {
            PrintWriter writer = response.getWriter();
            writer.print(JSON.toJSONString(r));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
